const { REACT_APP_OUTPUT_PATH, REACT_APP_VIEWS_PATH, REACT_APP_OUTPUT_PUBLIC_PATH } = process.env
const { isProd, resolve, MODE_MULTIPLE } = require('./config/util')

module.exports = {
  mode: MODE_MULTIPLE, // MODE_MULTIPLE 多页面; MODE_SINGLE 单页面；
  publicPath:  isProd ? REACT_APP_OUTPUT_PUBLIC_PATH : '/', // 或者 package.json 配置 homepage // 打包路径
  outputPath: isProd ?resolve(REACT_APP_OUTPUT_PATH) : undefined, // 打包路径 修改路径后，public 依然打包到 build 路径
  filename: isProd ? resolve(REACT_APP_VIEWS_PATH, 'test.blade.php') : 'index.html', // TODO: mode = single 时候，需要这个参数, 默认值 index.html
  pages: [
    {
      name: 'login',
      path: ['pages','login'],
      title: '登录',
      filename: resolve(REACT_APP_VIEWS_PATH, 'login.html'),
    },
    {
      name: 'index',
      path: ['index'],
      title: '前台',
      filename: resolve(REACT_APP_VIEWS_PATH, 'index.html'),
    },
    {
      name: 'admin',
      path: ['admin'],
      title: '后台',
      filename: resolve(REACT_APP_VIEWS_PATH, 'admin.html'),
    },
    {
      name: 'inner',
      path: ['admin', 'pages'],
      title: '内部页面',
      filename: resolve(REACT_APP_VIEWS_PATH, 'inner.html'),
    },
    {
      name: 'bzResultManage',
      path: ['pages', 'xuqiubianzhi', 'bzResultManage'],
      title: '编制成果管理',
      filename: resolve(REACT_APP_VIEWS_PATH, 'bzResultManage.html'),
    },
    {
      name: 'kcResultManage',
      path: ['pages', 'xuqiubianzhi', 'kcResultManage'],
      title: '勘测成果管理',
      filename: resolve(REACT_APP_VIEWS_PATH, 'kcResultManage.html'),
    },
    {
      name: 'pmsUploadManage',
      path: ['pages', 'xuqiubianzhi', 'pmsUploadManage'],
      title: 'PMS上传管理',
      filename: resolve(REACT_APP_VIEWS_PATH, 'pmsUploadManage.html'),
    },
    {
      name: 'xqOutBound',
      path: ['pages', 'xuqiubianzhi', 'xqOutBound'],
      title: '需求预出库',
      filename: resolve(REACT_APP_VIEWS_PATH, 'xqOutBound.html'),
    },
    {
      name: 'xqStore',
      path: ['pages', 'xuqiubianzhi', 'xqStore'],
      title: '需求储备库',
      filename: resolve(REACT_APP_VIEWS_PATH, 'xqStore.html'),
    },
    {
      name: 'xqSubmitManage',
      path: ['pages', 'xuqiubianzhi', 'xqSubmitManage'],
      title: '需求提报管理',
      filename: resolve(REACT_APP_VIEWS_PATH, 'xqSubmitManage.html'),
    },
    {
      name: 'xqTast',
      path: ['pages', 'xuqiubianzhi', 'xqTast'],
      title: '需求任务库',
      filename: resolve(REACT_APP_VIEWS_PATH, 'xqTast.html'),
    },
    {
      name: 'xqZuofei',
      path: ['pages', 'xuqiubianzhi', 'xqZuofei'],
      title: '需求作废库',
      filename: resolve(REACT_APP_VIEWS_PATH, 'xqZuofei.html'),
    },
    {
      name: 'yxpx',
      path: ['pages', 'xuqiubianzhi', 'yxpx'],
      title: '优选排序',
      filename: resolve(REACT_APP_VIEWS_PATH, 'yxpx.html'),
    }
  ], // TODO: mode = multiple 需要这个参数
  devServer: {
    historyApiFallback: {
      rewrites: [
        // { from: /^\/admin/, to: '/admin.html' }
        {
          from: /^\//,
          to: '/index.html'
        }
      ]
    }
  }
}